//
//  UTSUIImagePickerControllerDelegate.swift
//  UTSImagePickerLib
//
//  Created by Admin on 2024/8/2.
//

import UIKit
import PhotosUI

public typealias CPPickerImageFinishHandle = (_ picker: UIImagePickerController, _ info:[UIImagePickerController.InfoKey : Any]) -> Void
public typealias CPPickerImageCancelHandle = (_ picker: UIImagePickerController) -> Void

public class UTSUIImagePickerControllerDelegate: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    
    public var cancelHandle: CPPickerImageCancelHandle?
    public var finishHandle: CPPickerImageFinishHandle?
    
    public func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        self.cancelHandle?(picker)
    }
    
    public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        self.finishHandle?(picker, info)
    }
}



@available(iOS 14.0, *)
public typealias CPPHPickerHandle = (_ picker: PHPickerViewController, _ results: [PHPickerResult]) -> Void
@available(iOS 14.0, *)
public class UTSPHPickerViewControllerDelegate: NSObject, PHPickerViewControllerDelegate {
    @available(iOS 14.0, *)
    
    
    public var finishHandle: CPPHPickerHandle?
    
    @available(iOS 14.0, *)
    public func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
       self.finishHandle?(picker, results)
    }
}


func test() {
    let delegate = UTSUIImagePickerControllerDelegate()
     delegate.cancelHandle = { picker in
         
     }
     delegate.finishHandle = {
         (picker, info) in
     }
    
//
//    
//    let pickerController = UIImagePickerController()
//    let aaa: String = kUTTypeImage as String
////    let str: String = UTTypeImage
////    let typeStr: String = UTType.image
//    pickerController.mediaTypes = [kUTTypeImage as String]
}

func newTest() {
   
    
}
